/*
 * @Description:
 * @Version: 1.0
 * @Autor: laikt
 * @Date: 2020-12-30 10:43:50
 * @LastEditors: laikt
 * @LastEditTime: 2020-12-30 17:23:41
 */
import env from '@/env'
import * as cookies from './modules/cookies'
import * as db from './modules/db'
import * as fn from './modules/fn'
import * as helper from './modules/helper'
import * as log from './modules/log'
import * as time from './modules/time'
import * as math from './modules/math'

const utils = {
    cookies,
    time,
    db,
    fn,
    helper,
    log,
    math,
    import: require('./modules/import-' + env.NODE_ENV)
}

/**
 * @description 更新标题
 * @param {String} title 标题
 */
utils.title = function(titleText) {
    const processTitle = env.VUE_APP_TITLE || '组件'
    window.document.title = `${processTitle}${
        titleText ? ` | ${titleText}` : ''
    }`
}

/**
 * @description 打开新页面
 * @param {String} url 地址
 */
utils.open = function(url) {
    var a = document.createElement('a')
    a.setAttribute('href', url)
    a.setAttribute('target', '_blank')
    document.body.appendChild(a)
    a.click()
}

export default utils
